<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ECMAScript 6 简介</title>
</head>
<body>
    <h1>ECMAScript 6 简介</h1>

    <script>
        // ECMAScript 6 的新特性示例
        
        // 1. let和const
        let x = 1;
        const PI = 3.14159;

        // 2. 箭头函数
        const sum = (a, b) => a + b;

        // 3. 解构赋值
        const [a, b] = [1, 2];
        const { name, age } = { name: '张三', age: 20 };

        // 4. 模板字符串
        const user = '张三';
        console.log(`你好, ${user}!`);

        // 5. Promise对象
        new Promise((resolve, reject) => {
            setTimeout(() => resolve('done'), 1000);
        });

        // 6. Class类
        class Person {
            constructor(name) {
                this.name = name;
            }
            sayHello() {
                console.log(`Hello, ${this.name}!`);
            }
        }

        // 7. 模块化
        // export const myFunction = () => {};
        // import { myFunction } from './module.js';

        // 8. Set和Map数据结构
        const set = new Set([1, 2, 3]);
        const map = new Map([['key', 'value']]);

        // 9. Symbol
        const symbol = Symbol('description');

        // 10. 代理和反射
        const proxy = new Proxy({}, {
            get: function(target, property) {
                return 35;
            }
        });
    </script>
</body>
</html> 